package com.ymatou.iapi.sellerquery.testcase;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.sellerquery.parameter.GetOrderFlowsBean;
import com.ymatou.iapi.sellerquery.parameter.resp.GetOrderFlowsResp;
import com.ymatou.iapi.sellerquery.parameter.vo.FlowsDetail;
import com.ymatou.iapi.sellerquery.service.GetOrderFlowsCall;
import com.ymatou.iapi.trading.operate.parameter.ActivityVo;
import com.ymatou.iapi.trading.operate.parameter.OrderGroupVo;
import com.ymatou.iapi.trading.operate.parameter.OrderItemVo;
import com.ymatou.iapi.trading.operate.parameter.OrderVo;
import com.ymatou.iapi.trading.operate.parameter.SellerCouponVo;
import com.ymatou.iapi.trading.operate.parameter.YmatouCouponVo;
import com.ymatou.iapi.trading.operate.parameter.enums.ActivityPromotionTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.AppTerminalSourceEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.LogisticsTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.OrderSourceEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.OrderTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.PriceTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.ProductRefundChannelEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.SalesTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.SellerCouponApplianceTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.TerminalSourceEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.YmatouCouponApplianceTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.req.PlaceOrderReq;
import com.ymatou.iapi.trading.operate.parameter.req.SalesRefundSuccessRequestBean;
import com.ymatou.iapi.trading.operate.service.PlaceOrderCall;
import com.ymatou.iapi.trading.operate.service.SalesRefundSuccessRequestCall;
import com.ymatou.query.seller.trading.api.service.OrderCreate;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P3;
import com.ymttest.business.service.CouponCallService;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.business.service.ProductCallService;
import com.ymttest.database.model.YmtRefundBill;
import com.ymttest.database.sqlwapper.DefaultWapper;
import com.ymttest.database.sqlwapper.YmtRefundWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
import com.ymttest.utils.constant.ECode;

@TestSuite
public class Ts_GetOrderFlows {
	
	/**
	 * 获取订单资金流信息FreeMaker Template自动生成代码
	 */
	

		private static GetOrderFlowsBean getorderflowsbean;
		private static GetOrderFlowsCall getorderflowscall;
		private static com.ymatou.query.seller.trading.api.service.GetOrderFlowsCall getorderflowscall_net;
		
		
		@BeforeClass
		public static void setUp() {
			Logger.createResultFile("获取订单资金流信息");
		}

		@Before
		public void caseUp() {

			getorderflowsbean = new GetOrderFlowsBean();
			getorderflowscall = new GetOrderFlowsCall();
			getorderflowscall_net=new com.ymatou.query.seller.trading.api.service.GetOrderFlowsCall();
		}

		@AfterClass
		public static void tearDown() {
			Logger.generateResult(getorderflowscall.getOpurl());
		}

		@After
		public void caseDown() {
			Logger.end();
		}

	
		   // 一个订单下面多个商品
	    private Map placeOrder() {
	        Map map = new HashMap();
	        try {
	            PlaceOrderReq placeorderBean = new PlaceOrderReq();
	            PlaceOrderCall placeorderCall = new PlaceOrderCall();
	            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
	            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
	            // 创建产品
	            Logger.comment("前置数据准备");
	            HashMap<String, Object> productInfo = ProductCallService
	                    .createProduct(sellerId, 3);
	            Logger.comment("前置数据准备结束");
	            String productId = (String) productInfo.get("productId");
	            Logger.debug("productId:" + productId);
	            String productName = (String) productInfo.get("productName");
	            String pic = (String) productInfo.get("pic");
	            BigDecimal price = (BigDecimal) (productInfo.get("price"));
	            String catalogId = (String) productInfo.get("catalogId");
	            YmatouCouponVo ymtCoupon = new YmatouCouponVo();
	            // 平台优惠券
	            BigDecimal couponValue = new BigDecimal(13);
	            String couponCode = new OrderCallService().receivePlatformCoupon(userId, couponValue);
	            ymtCoupon.setApplianceType(YmatouCouponApplianceTypeEnum.ALL);
	            ymtCoupon.setCouponCode(couponCode);
	            ymtCoupon.setCouponValue(couponValue);
	            placeorderBean.setAppId("AutoTest");
	            placeorderBean.setYmatouCoupon(ymtCoupon);
	            placeorderBean.setUserId(userId);
	            placeorderBean.setRequestId(TestDataManager.getRandomUUID()
	                    .toString());
	            placeorderBean.setTerminalSource(TerminalSourceEnum.IOS);
	            placeorderBean.setAppTerminalSource(AppTerminalSourceEnum.Phone);
	            placeorderBean.setSourceIp("127.0.0.1");
	            placeorderBean.setAppId("ios");
	            placeorderBean.setDeviceId("7777777777888888888888999");
	            OrderGroupVo groupVo1 = new OrderGroupVo();
	            placeorderBean.setOrderSource(OrderSourceEnum.PC);
	            // 商家优惠券
	            BigDecimal sellerCouponValue = new BigDecimal(15);
	            String sellerCouponCode = new CouponCallService().receiveCouponInfo(sellerId, userId,
	                    couponValue);
	            SellerCouponVo sellerCoupon = new SellerCouponVo();
	            sellerCoupon.setApplianceType(SellerCouponApplianceTypeEnum.ALL);
	            sellerCoupon.setCouponCode(sellerCouponCode);
	            sellerCoupon.setCouponValue(sellerCouponValue);
	            groupVo1.setSellerCoupon(sellerCoupon);
	            groupVo1.setSellerId(sellerId);
	            List<OrderVo> orders = new ArrayList<OrderVo>();
	            OrderVo ordervo1 = new OrderVo();
	            ordervo1.setAutoCancelOrderHours(new BigDecimal(1));
	            ordervo1.setOrderType(OrderTypeEnum.Spot);
	            ordervo1.setPaidFull(true);
	            ordervo1.setAddress("上海市闸北区灵石路636号");
	            ordervo1.setLeaveWord("ymt autotest");
	            ordervo1.setPhone("13100000001");
	            ordervo1.setPostCode("200001");
	            ordervo1.setTelephone("021-51002100");
	            ordervo1.setReceiveName("李四");
	            List<OrderItemVo> items = new ArrayList<OrderItemVo>();
	            OrderItemVo orderitem1 = new OrderItemVo();
	            orderitem1.setCatalogId(TestDataManager.getRandomUUID().toString());
	            orderitem1.setProductNum(3);
	            orderitem1.setProductName(productName);
	            orderitem1.setPriceType(PriceTypeEnum.VipPrice);
	            orderitem1.setProductId(TestDataManager.getRandomUUID().toString());
	            price = new BigDecimal(210);
	            orderitem1.setEarnestPrice(price);
	            orderitem1.setProductPrice(price);
	            orderitem1.setOriginalPrice(price);
	            orderitem1.setSalesType(SalesTypeEnum.AlreadyInStock);
	            orderitem1.setLogisticsType(LogisticsTypeEnum.SailProtect);
	            orderitem1.setProductRefundChannel(ProductRefundChannelEnum.Official);
	            orderitem1.setBrandId(5);
	            orderitem1.setPackageNo("11111111");
	            orderitem1.setFirstCategoryId(111111111);
	            orderitem1.setSecondCategoryId(22222222);
	            orderitem1.setThirdCategoryId(3333333);
	            orderitem1
	                    .setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
	            orderitem1.setProductRecordNo("1234567");
	            orderitem1.setProductRefundChannel(ProductRefundChannelEnum.Official);
	            orderitem1
	                    .setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
	            ActivityVo activity = new ActivityVo();
	            activity.setActivityId(46870);
	            activity.setActivityBeginDate(YMTDateUtil.getBeforeOrNextDay(-10, "yyyy-MM-dd'T'HH:mm:ss"));
	            activity.setActivityEndDate(YMTDateUtil.getBeforeOrNextDay(10, "yyyy-MM-dd'T'HH:mm:ss"));
	            activity.setActivityTemplateId(12345678);
	            activity.setCommissionRate(new BigDecimal(1.1));
	            activity.setCost(true);
	            activity.setFeeFree(false);
	            activity.setPremium(new BigDecimal(1.5));
	            activity.setPromotionPrice(new BigDecimal(15));
	            activity.setPromotionType(ActivityPromotionTypeEnum.DiscountRate);
	            activity.setUseCoupon(true);
	            orderitem1.setActivity(activity);
	            ordervo1.setOrderItems(items);
	            ordervo1.setFreight(new BigDecimal("21"));
	            // 第2件商品
	            OrderItemVo orderitem2 = new OrderItemVo();
	            orderitem2.setCatalogId(TestDataManager.getRandomUUID().toString());
	            orderitem2.setProductNum(1);
	            orderitem2.setProductName(productName);
	            orderitem2.setPriceType(PriceTypeEnum.VipPrice);
	            orderitem2.setProductId(TestDataManager.getRandomUUID().toString());
	            price = new BigDecimal(270);
	            orderitem2.setEarnestPrice(price);
	            orderitem2.setProductPrice(price);
	            orderitem2.setOriginalPrice(price);
	            orderitem2.setSalesType(SalesTypeEnum.AlreadyInStock);
	            orderitem2.setLogisticsType(LogisticsTypeEnum.SailProtect);
	            orderitem2.setProductRefundChannel(ProductRefundChannelEnum.Official);
	            orderitem2.setBrandId(5);
	            orderitem2.setPackageNo("11111111");
	            orderitem2.setFirstCategoryId(111111111);
	            orderitem2.setSecondCategoryId(22222222);
	            orderitem2.setThirdCategoryId(3333333);
	            orderitem2
	                    .setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
	            orderitem2.setProductRecordNo("1234567");
	            orderitem2.setProductRefundChannel(ProductRefundChannelEnum.Official);
	            orderitem2
	                    .setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
	            orderitem2.setActivity(activity);
	            items.add(orderitem1);
	            items.add(orderitem2);
	            ordervo1.setOrderItems(items);
	            ordervo1.setFreight(new BigDecimal("21"));
	            orders.add(ordervo1);
	            groupVo1.setOrders(orders);
	            placeorderBean.setOrderGroups(Arrays.asList(groupVo1));
	            placeorderCall.setData(false, placeorderBean);
	            placeorderCall.callService();
	            JSONArray orderIds = placeorderCall.getOrderIds();
	            int tradingId = placeorderCall.getTradingId();
	            map.put("orderIds", orderIds);
	            map.put("tradingId", tradingId);
	        } catch (Exception e) {
	            Logger.fail(e);
	        }
	        return map;
	    }
	    private  void verify(List<com.ymatou.query.seller.trading.api.parameter.resp.GetOrderFlowsResp> getOrderFlowsRespList_net) {	
			//解析接口返回json
			List<GetOrderFlowsResp>  getOrderFlowsRespList=getorderflowscall.getOrderFlowsResp();		   	
	    	Logger.comment("校验java重构跟.net接口返回结果");	
			for(int i=0;i<getOrderFlowsRespList_net.size();i++){
				Logger.verifyEquals(getOrderFlowsRespList_net.get(i).getTime().split("\\.")[0], getOrderFlowsRespList.get(i).getTime(), "验证time");		
				Logger.verifyEquals(getOrderFlowsRespList_net.get(i).getOperation(), getOrderFlowsRespList.get(i).getOperation(), "验证operation");		
				Logger.verifyEquals(getOrderFlowsRespList_net.get(i).getEvidence(), getOrderFlowsRespList.get(i).getEvidence(), "验证evidence");		
				Logger.verifyEquals(getOrderFlowsRespList_net.get(i).getCouponChannel(), getOrderFlowsRespList.get(i).getCouponChannel(), "验证couponChannel");		
				Logger.verifyEquals(getOrderFlowsRespList_net.get(i).getCouponCode(), getOrderFlowsRespList.get(i).getCouponCode(), "验证couponCode");		
				Logger.verifyEquals(getOrderFlowsRespList_net.get(i).getFreeCard(), getOrderFlowsRespList.get(i).getFreeCard(), "验证freeCard");		
				Logger.verifyEquals(getOrderFlowsRespList_net.get(i).getPriceChange(), getOrderFlowsRespList.get(i).getPriceChange(), "验证priceChange");		
				Logger.verifyEquals(getOrderFlowsRespList_net.get(i).getTotal(), getOrderFlowsRespList.get(i).getTotal(), "验证total");
				Logger.verifyEquals(getOrderFlowsRespList_net.get(i).getCash(), getOrderFlowsRespList.get(i).getCash(), "验证cash");		
				Logger.verifyEquals(getOrderFlowsRespList_net.get(i).getGift(), getOrderFlowsRespList.get(i).getGift(), "验证gift");		
				Logger.verifyEquals(getOrderFlowsRespList_net.get(i).getCoupon(), getOrderFlowsRespList.get(i).getCoupon(), "验证coupon");		
				Logger.verifyEquals(getOrderFlowsRespList_net.get(i).getAccountPaidAmount(), getOrderFlowsRespList.get(i).getAccountPaidAmount(), "验证accountPaidAmount");		
				Logger.verifyEquals(getOrderFlowsRespList_net.get(i).getThirdPartyPaidAmount(), getOrderFlowsRespList.get(i).getThirdPartyPaidAmount(), "验证thirdPartyPaidAmount");		
				Logger.verifyEquals(getOrderFlowsRespList_net.get(i).getThirdPartyName(), getOrderFlowsRespList.get(i).getThirdPartyName(), "验证thirdPartyName");		
				Logger.verifyEquals(getOrderFlowsRespList_net.get(i).getSellerCouponCode(), getOrderFlowsRespList.get(i).getSellerCouponCode(), "验证sellerCouponCode");		
				Logger.verifyEquals(getOrderFlowsRespList_net.get(i).getSellerCoupon(), getOrderFlowsRespList.get(i).getSellerCoupon(), "验证sellerCoupon");		
				Logger.verifyEquals(getOrderFlowsRespList_net.get(i).isIsIncoming(), getOrderFlowsRespList.get(i).isIncoming(), "验证isIncoming");			
			}		
		}
		@Test
		@Category(P1.class)
		@TestCase
		public void Tc_GetOrderFlows_001() {
			Logger.start(true,"根据OrderId获取订单资金流信息,成功");
			try {
		        OrderCallService orderCallService = new OrderCallService();
	            SalesRefundSuccessRequestBean salesrefundsuccessrequestBean=new SalesRefundSuccessRequestBean();
	            SalesRefundSuccessRequestCall salesrefundsuccessrequestCall=new SalesRefundSuccessRequestCall();
	            Map map = placeOrder();
	            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
	            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
	            JSONArray orderIds = (JSONArray) map.get("orderIds");
	            int tradingId = (Integer) map.get("tradingId");
	            int orderId = orderIds.getInt(0);
	            // 付款金额
	            BigDecimal amount = orderCallService.getNeedPrePayAmountOfCash(orderId);
	            // 付款
	            orderCallService.orderPayRequest(userId, amount, tradingId);
	            // 卖家接单
	            orderCallService.acceptOrder(orderId, sellerId);
	            // 申请退款
	            orderCallService.applySalesRefundRequestInJava(orderId);        
	            String param="OrderId="+orderId;          
				getorderflowscall.setData(param);
				getorderflowscall.callService();
				//.net 接口请求		
				getorderflowscall_net.setData(param);
				getorderflowscall_net.callService();								
				//解析接口返回json
				List<com.ymatou.query.seller.trading.api.parameter.resp.GetOrderFlowsResp>  getOrderFlowsRespList_net=getorderflowscall_net.getOrderFlowsResp();					
				Logger.verifyEquals(ECode.SUCCESS, getorderflowscall.getCode(),
						"验证code");
				Logger.verifyEquals(0, getorderflowscall.getBCode(), "验证bcode");
				verify(getOrderFlowsRespList_net);
			} catch (Exception e) {
				Logger.fail(e);
			}
		}	
		
		
		@Test
		@Category(P1.class)
		@TestCase
		public void Tc_GetOrderFlows_002() {
			Logger.start(true,"根据OrderId获取有退款退货订单信息,成功");
			try {
		        OrderCallService orderCallService = new OrderCallService();
	            SalesRefundSuccessRequestBean salesrefundsuccessrequestBean=new SalesRefundSuccessRequestBean();
	            SalesRefundSuccessRequestCall salesrefundsuccessrequestCall=new SalesRefundSuccessRequestCall();
	            Map map = placeOrder();
	            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
	            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
	            JSONArray orderIds = (JSONArray) map.get("orderIds");
	            int tradingId = (Integer) map.get("tradingId");
	            int orderId = orderIds.getInt(0);
	            // 付款金额
	            BigDecimal amount = orderCallService.getNeedPrePayAmountOfCash(orderId);
	            // 付款
	            orderCallService.orderPayRequest(userId, amount, tradingId);
	            // 卖家接单
	            orderCallService.acceptOrder(orderId, sellerId);
	            // 申请退款            
	            orderCallService.salesRefundSuccessRequestAllProducts(orderId);            
	            String param="OrderId="+orderId;          
				getorderflowscall.setData(param);
				getorderflowscall.callService();
				//.net 接口请求		
				getorderflowscall_net.setData(param);
				getorderflowscall_net.callService();								
				//解析接口返回json
				List<com.ymatou.query.seller.trading.api.parameter.resp.GetOrderFlowsResp>  getOrderFlowsRespList_net=getorderflowscall_net.getOrderFlowsResp();					
				Logger.verifyEquals(ECode.SUCCESS, getorderflowscall.getCode(),
						"验证code");
				Logger.verifyEquals(0, getorderflowscall.getBCode(), "验证bcode");
				verify(getOrderFlowsRespList_net);
			} catch (Exception e) {
				Logger.fail(e);
			}
		}	
		@Test
		@Category(P1.class)
		@TestCase
		public void Tc_GetOrderFlows_003() {
			Logger.start(true,"订单商品申请退款中,根据orderid查询成功");
			try {
		        OrderCallService orderCallService = new OrderCallService();
	            SalesRefundSuccessRequestBean salesrefundsuccessrequestBean=new SalesRefundSuccessRequestBean();
	            SalesRefundSuccessRequestCall salesrefundsuccessrequestCall=new SalesRefundSuccessRequestCall();
	            Map map = placeOrder();
	            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
	            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
	            JSONArray orderIds = (JSONArray) map.get("orderIds");
	            int tradingId = (Integer) map.get("tradingId");
	            int orderId = orderIds.getInt(0);
	            // 付款金额
	            BigDecimal amount = orderCallService.getNeedPrePayAmountOfCash(orderId);
	            // 付款
	            orderCallService.orderPayRequest(userId, amount, tradingId);
	            // 卖家接单
	            orderCallService.acceptOrder(orderId, sellerId);
	            // 申请退款            
	            orderCallService.applySalesRefundRequestInJava(orderId);
	            String param="OrderId="+orderId;          
				getorderflowscall.setData(param);
				getorderflowscall.callService();
				//解析接口返回json
				List<GetOrderFlowsResp>  getOrderFlowsRespList=getorderflowscall.getOrderFlowsResp();								
				getorderflowscall_net.setData(param);
				getorderflowscall_net.callService();								
				//.net 接口请求		
				getorderflowscall_net.setData(param);
				getorderflowscall_net.callService();								
				//解析接口返回json
				List<com.ymatou.query.seller.trading.api.parameter.resp.GetOrderFlowsResp>  getOrderFlowsRespList_net=getorderflowscall_net.getOrderFlowsResp();					
				Logger.verifyEquals(ECode.SUCCESS, getorderflowscall.getCode(),
						"验证code");
				Logger.verifyEquals(0, getorderflowscall.getBCode(), "验证bcode");
				verify(getOrderFlowsRespList_net);
			} catch (Exception e) {
				Logger.fail(e);
			}
		}	
		@Test
		@Category(P1.class)
		@TestCase
		public void Tc_GetOrderFlows_004() {
			Logger.start(true,"订单商品退款拒绝,根据orderid查询成功");
			try {
		        OrderCallService orderCallService = new OrderCallService();
	            SalesRefundSuccessRequestBean salesrefundsuccessrequestBean=new SalesRefundSuccessRequestBean();
	            SalesRefundSuccessRequestCall salesrefundsuccessrequestCall=new SalesRefundSuccessRequestCall();
	            Map map = placeOrder();
	            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
	            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
	            JSONArray orderIds = (JSONArray) map.get("orderIds");
	            int tradingId = (Integer) map.get("tradingId");
	            int orderId = orderIds.getInt(0);
	            // 付款金额
	            BigDecimal amount = orderCallService.getNeedPrePayAmountOfCash(orderId);
	            // 付款
	            orderCallService.orderPayRequest(userId, amount, tradingId);
	            // 卖家接单
	            orderCallService.acceptOrder(orderId, sellerId);
	            // 申请退款            
	            orderCallService.salesRefundSuccessRequestAllProducts(orderId);
	            String param="OrderId="+orderId;          
				getorderflowscall.setData(param);
				getorderflowscall.callService();
				//解析接口返回json
				List<GetOrderFlowsResp>  getOrderFlowsRespList=getorderflowscall.getOrderFlowsResp();								
				getorderflowscall_net.setData(param);
				getorderflowscall_net.callService();								
				//.net 接口请求		
				getorderflowscall_net.setData(param);
				getorderflowscall_net.callService();								
				//解析接口返回json
				List<com.ymatou.query.seller.trading.api.parameter.resp.GetOrderFlowsResp>  getOrderFlowsRespList_net=getorderflowscall_net.getOrderFlowsResp();					
				Logger.verifyEquals(ECode.SUCCESS, getorderflowscall.getCode(),
						"验证code");
				Logger.verifyEquals(0, getorderflowscall.getBCode(), "验证bcode");
				verify(getOrderFlowsRespList_net);
			} catch (Exception e) {
				Logger.fail(e);
			}
		}	
		@Test
		@Category(P1.class)
		@TestCase
		public void Tc_GetOrderFlows_005() {
			Logger.start(true,"订单商品部分退款成功,根据orderid查询成功");
			try {
		        OrderCallService orderCallService = new OrderCallService();
	            SalesRefundSuccessRequestBean salesrefundsuccessrequestBean=new SalesRefundSuccessRequestBean();
	            SalesRefundSuccessRequestCall salesrefundsuccessrequestCall=new SalesRefundSuccessRequestCall();
	            Map map = placeOrder();
	            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
	            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
	            JSONArray orderIds = (JSONArray) map.get("orderIds");
	            int tradingId = (Integer) map.get("tradingId");
	            int orderId = orderIds.getInt(0);
	            // 付款金额
	            BigDecimal amount = orderCallService.getNeedPrePayAmountOfCash(orderId);
	            // 付款
	            orderCallService.orderPayRequest(userId, amount, tradingId);
	            // 卖家接单
	            orderCallService.acceptOrder(orderId, sellerId);
	            // 申请部分退款
	            orderCallService.salesrefundsuccessrequest(orderCallService.applySalesRefundRequestInJava(orderId));          
	            String param="OrderId="+orderId;          
				getorderflowscall.setData(param);
				getorderflowscall.callService();
				//解析接口返回json
				List<GetOrderFlowsResp>  getOrderFlowsRespList=getorderflowscall.getOrderFlowsResp();								
				getorderflowscall_net.setData(param);
				getorderflowscall_net.callService();								
				//.net 接口请求		
				getorderflowscall_net.setData(param);
				getorderflowscall_net.callService();								
				//解析接口返回json
				List<com.ymatou.query.seller.trading.api.parameter.resp.GetOrderFlowsResp>  getOrderFlowsRespList_net=getorderflowscall_net.getOrderFlowsResp();					
				Logger.verifyEquals(ECode.SUCCESS, getorderflowscall.getCode(),
						"验证code");
				Logger.verifyEquals(0, getorderflowscall.getBCode(), "验证bcode");
				verify(getOrderFlowsRespList_net);
			} catch (Exception e) {
				Logger.fail(e);
			}
		}	
		@Test
		@Category(P1.class)
		@TestCase
		public void Tc_GetOrderFlows_006() {
			Logger.start(true,"订单部分商品拒绝退款,根据orderid查询成功");
			try {
		        OrderCallService orderCallService = new OrderCallService();
	            SalesRefundSuccessRequestBean salesrefundsuccessrequestBean=new SalesRefundSuccessRequestBean();
	            SalesRefundSuccessRequestCall salesrefundsuccessrequestCall=new SalesRefundSuccessRequestCall();
	            Map map = placeOrder();
	            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
	            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
	            JSONArray orderIds = (JSONArray) map.get("orderIds");
	            int tradingId = (Integer) map.get("tradingId");
	            int orderId = orderIds.getInt(0);
	            // 付款金额
	            BigDecimal amount = orderCallService.getNeedPrePayAmountOfCash(orderId);
	            // 付款
	            orderCallService.orderPayRequest(userId, amount, tradingId);
	            // 卖家接单
	            orderCallService.acceptOrder(orderId, sellerId);
	            // 申请部分退款
	            orderCallService.salesrefundfailrequest(orderCallService.applySalesRefundRequestInJava(orderId));          
	            String param="OrderId="+orderId;          
				getorderflowscall.setData(param);
				getorderflowscall.callService();
				//解析接口返回json
				List<GetOrderFlowsResp>  getOrderFlowsRespList=getorderflowscall.getOrderFlowsResp();								
				getorderflowscall_net.setData(param);
				getorderflowscall_net.callService();								
				//.net 接口请求		
				getorderflowscall_net.setData(param);
				getorderflowscall_net.callService();								
				//解析接口返回json
				List<com.ymatou.query.seller.trading.api.parameter.resp.GetOrderFlowsResp>  getOrderFlowsRespList_net=getorderflowscall_net.getOrderFlowsResp();					
				Logger.verifyEquals(ECode.SUCCESS, getorderflowscall.getCode(),
						"验证code");
				Logger.verifyEquals(0, getorderflowscall.getBCode(), "验证bcode");
				verify(getOrderFlowsRespList_net);
			} catch (Exception e) {
				Logger.fail(e);
			}
		}
		@Test
		@Category(P3.class)
		@TestCase
		public void Tc_GetOrderFlows_007() {
			Logger.start(false,"orderid不存在");
			try {
				int orderId=11111111;
	            String param="OrderId="+orderId;          
				getorderflowscall.setData(param);
				getorderflowscall.callService();
				getorderflowscall_net.setData(param);
				getorderflowscall_net.callService();								
		 
				Logger.verifyEquals(ECode.SUCCESS, getorderflowscall.getCode(),
						"验证code");
				Logger.verifyEquals(0, getorderflowscall.getBCode(), "验证bcode");
				Logger.verifyEquals(getorderflowscall_net.getData().getBoolean("IsShangouOrder"), getorderflowscall.getData().getBoolean("IsShangouOrder"), "验证java重构跟.net接口返回 IsShangouOrder 字段");
				Logger.verifyEquals(getorderflowscall_net.getData().getString("Flows"), getorderflowscall.getData().getString("flows"), "验证java重构跟.net接口返回");
				
			} catch (Exception e) {
				Logger.fail(e);
			}
		}	
		@Test
		@Category(P3.class)
		@TestCase
		public void Tc_GetOrderFlows_008() {
			Logger.start(false,"orderid为null");
			try {				
	            String param="OrderId=";          
				getorderflowscall.setData(param);
				getorderflowscall.callService();
				//解析接口返回json
				Logger.verifyEquals("", getorderflowscall.getReturnData(), "验证java重构跟.net接口返回 IsShangouOrder 字段");				
			} catch (Exception e) {
				Logger.fail(e);
			}
		}	
	
	}


